﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace linkouqs.Gamekit
{

    public class CharacterDebugJumpHeight : MonoBehaviour
    {

        CharacterController2D m_Character;

        float m_StartY;

        bool m_IsGround;

        float m_LastY;

        bool m_Jumping;

        void Awake()
        {
            m_Character = GetComponent<CharacterController2D>();
            m_IsGround = m_Character.IsGround;
        }

        void FixedUpdate()
        {

            if (!m_Character.IsGround)
            {
                if (m_IsGround)
                {
                    m_StartY = m_LastY;
                    m_Jumping = true;
                }

            }

            if(m_Jumping)
            {
                if (transform.position.y < m_LastY)
                {
                    Debug.LogWarning(m_LastY - m_StartY);
                    m_Jumping = false;
                }
            }

            m_LastY = transform.position.y;
            m_IsGround = m_Character.IsGround;
        }
    }

}
